Skip to content

fix: concurrent map writes (#861)#862

Open
jay376 wants to merge 1 commit intonacos-group:masterfrom
jay376:fix-concurrent-write
Open

fix: concurrent map writes (#861)#862
jay376 wants to merge 1 commit intonacos-group:masterfrom
jay376:fix-concurrent-write

Conversation

@jay376
Copy link

@jay376 jay376 commented Dec 3, 2025

Add your commit body here

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


zhangfangjie seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@lingma-agents
Copy link

lingma-agents bot commented Dec 3, 2025

修复并发写入clientMap导致的竞态条件问题

变更概述
  • 问题修复
    • 修复了在多协程环境下对全局变量clientMap进行并发写操作时可能引发的竞态条件问题
    • Shutdown方法中添加了互斥锁(cMux)来保护对clientMap的删除操作
    • 确保在高并发场景下程序的稳定性和数据一致性

实现细节:

  • 在删除clientMap条目前获取锁:cMux.Lock()
  • 执行删除操作:delete(clientMap, r.name)
  • 删除完成后释放锁:cMux.Unlock()

此修复解决了由于并发访问共享资源而可能导致的数据竞争和程序崩溃问题。

变更文件
文件路径 变更说明
common/​remote/​rpc/​rpc_​client.​go 在Shutdown方法中增加互斥锁保护,防止并发删除clientMap时出现竞态条件。

💡 小贴士

与 lingma-agents 交流的方式

📜 直接回复评论
直接回复本条评论,lingma-agents 将自动处理您的请求。例如:

  • 在当前代码中添加详细的注释说明。

  • 请详细介绍一下你说的 LRU 改造方案,并使用伪代码加以说明。

📜 在代码行处标记
在文件的特定位置创建评论并 @lingma-agents。例如:

  • @lingma-agents 分析这个方法的性能瓶颈并提供优化建议。

  • @lingma-agents 对这个方法生成优化代码。

📜 在讨论中提问
在任何讨论中 @lingma-agents 来获取帮助。例如:

  • @lingma-agents 请总结上述讨论并提出解决方案。

  • @lingma-agents 请根据讨论内容生成优化代码。

@jay376 jay376 changed the title fix: councurrent map writes (#861) fix: concurrent map writes (#861) Dec 3, 2025
@jay376 jay376 force-pushed the fix-concurrent-write branch from c640510 to 5e4a769 Compare December 3, 2025 03:33
@jay376 jay376 force-pushed the fix-concurrent-write branch from 5e4a769 to c6a3ace Compare December 3, 2025 03:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants